package widgets
{
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	public class Tip extends MovieClip
	{
		public function Tip()
		{
			super();
			init();
		}
		private var shape:Shape;
		private var txt:TextField;
		
		public function init():void
		{
			this.shape= new Shape();
			shape.graphics.lineStyle(1,0xCCCCCC,0.4);
			shape.graphics.beginFill(0,0.6);
			shape.graphics.drawRoundRect(0,0,80,20,20,20);
			shape.graphics.endFill();
			
			this.txt = new TextField();
			
			this.addChild(shape);
			this.addChild(txt);
			
		}
		public function SetText(value:String):void
		{
			this.txt.text = value;
			var tf:TextFormat = new TextFormat();
			tf.font = "Microsoft JhengHei";
			tf.color = 0xFFFFFF;
			this.txt.setTextFormat(tf);
			UpdateGraphicsSize();
		}
		
		public function UpdateGraphicsSize():void
		{
			var w:Number = this.txt.textWidth;
			this.shape.graphics.clear();
			shape.graphics.lineStyle(1,0xCCCCCC,0.4);
			shape.graphics.beginFill(0,0.6);
			shape.graphics.drawRoundRect(0,0,w+40,20,20,20);
			shape.graphics.endFill();
			this.txt.x = 18;
		}
		
	}
}